import 'package:flutter/material.dart';

class IconGridView extends StatelessWidget {
  // Mock 数据：每个列表项包含图标和文本
  final List<Map<String, String>> iconData = List.generate(
    8,
    (index) => {'icon': 'train', 'label': 'Train $index'},
  );

  IconGridView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Optimized Icon Grid"),
      ),
      body: Column(
        children: [
          _buildRow(),
          _buildRow(),
        ],
      ),
    );
  }

  // 用来构建每一行的 Widget
  Widget _buildRow() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: iconData
          .map(
            (data) => Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                const Icon(Icons.train, size: 40),
                Text(data['label']!),
              ],
            ),
          )
          .toList(),
    );
  }
}
